package com.yuxi.Dao.Impl;

import java.io.Serializable;
import java.util.List;

import javax.sound.midi.MidiDevice.Info;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.yuxi.Dao.InformationPortDao;
import com.yuxi.Entity.CommentRecordBrowse;
import com.yuxi.Entity.InformationPort;
import com.yuxi.Entity.InformationSource;
@Repository
public class InformationPortDaoImpl extends BaseDaoImpl<Serializable,Serializable> implements InformationPortDao {
	private Logger logger=LoggerFactory.getLogger(InformationPortDaoImpl.class);
	public InformationPortDaoImpl(){
		super(InformationPort.class);
	}


@Override
public InformationPort getInfoPort(Integer id) {
	// TODO Auto-generated method stub
	return (InformationPort) super.get(id);
}

@Override
public void deleteInfoPort(InformationPort informationPort) {
	// TODO Auto-generated method stub
	super.delete(informationPort);
}

@Override
public InformationPort addInfoPort(InformationPort informationPort) {
	// TODO Auto-generated method stub
	return (InformationPort)  super.addAndReturn(informationPort);
}

@Override
public void modifyInfoPort(InformationPort informationPort) {
	// TODO Auto-generated method stub
	super.update(informationPort);
}

@Override
public List<InformationPort> getAllInfoPort() {
	// TODO Auto-generated method stub
	return super.find("from InformationPort");
}


@Override
public List<InformationPort> getUserPort(Integer roleId){	
	
	return super.find(" select new InformationPort(portTable.id, portTable.portName, portTable.remark) from"
			+ " InformationPort portTable,InformationPortPower powerTable "
			+ "where portTable.id=powerTable.portId and roleId=? ",roleId);
}


@Override
public int getCountPort(Integer superId) {
	// TODO Auto-generated method stub
	return  super.execute("select count(id) from InformationPort where superId =?", superId);

}

@Override
public List<InformationPort> getPortBysuperId(Integer superId) {
	
	return super.find("from InformationPort where superId=? order by level",superId);
}


}
